import requests

from weixin.contact.conftest import token
from weixin.contact.token import Weixin


class User:
    def creat_by_template(self, data):
        return requests.post('https://qyapi.weixin.qq.com/cgi-bin/user/create',
                          params={"access_token": Weixin.get_token()},
                          data=data,
                          ).json()

    def creat(self, data, token):
        return requests.post("https://qyapi.weixin.qq.com/cgi-bin/user/create",
                          params={"access_token": token},
                          json=data
                          ).json()

    def list(self, department_id=1, **kwargs):
        return requests.get("https://qyapi.weixin.qq.com/cgi-bin/user/simplelist",
                         params={"access_token": Weixin.get_token(), "department_id": department_id},
                         ).json()